/**
 * Created by ACER on 2018/1/27.
 */
app.controller('user-login',function($scope,$http){
    $scope.username='';
    $scope.password='';

    $scope.login=function(){
        var loginInfo={'username':$scope.username,'password':$scope.password};
        $http({
            method: 'post',
            url: app.netPath+'/users/login',
            params: loginInfo
        }).then(function(res){
            console.log(res);
            if(!res.data.error){
                $.toast(res.data.msg);
                localStorage.setItem('token',res.data.data);
                location.href='#index';
            }
            else {
                $.toast(res.data.msg);
            }
        },function(){
            $.toast('网络或设置错误');
        });
    };
});